#pragma once

/*!
* \file  ui_multi_timer.h
* \brief 
* 
*
* 
* \author patdz@qq.com
* \version 1.0
* \date 2014/06/03
*/

#include "ui.h"
#include "ui_base.h"

_SSL_BEGIN
_SSUIL_BEGIN

#define kTimerIDAll 0

typedef struct _UITimerInfo
{
	unsigned int id;
	unsigned int interval;
	unsigned int elpase;
} UITimerInfo;
typedef std::list<UITimerInfo> UITimerInfos;

#define kMaxSysTimerID 500

#pragma warning(push)
#pragma warning(disable:4251)
#pragma warning(disable:4250)
class SSUI_CLASS UIMultiTimer :
	public IUITimerInterface,
	virtual public ref_counted_base
{
public:
	UIMultiTimer();
	virtual ~UIMultiTimer();

	// IUITimerInterface
public:
	virtual void OnTimer(unsigned int interval);

public:
	virtual int SetIDTimer(unsigned int timer_id, unsigned int elapse);
	virtual bool KillIDTimer(unsigned int timer_id = 0);

	//
protected:
	virtual void OnTimerCB(unsigned int timer_id) = 0;
	virtual void TrySetTimerOnWindowManager() = 0;
	virtual void KillTimerOnWindowManager() = 0;

protected:
	cs_lock timer_infos_lock_;
	UITimerInfos timer_infos_;
	unsigned int auto_timer_id_index_;
};
#pragma warning(pop)

_SSUIL_END
_SSL_END
